A digital filter is widely applied in the image or video field, mainly for pre-processing, post-processing, and special effect processing of images or videos. In an application of pre-processing of images or videos, the digital filter may be used for demosaicking0 color interpolation to suppress imaging noise, and may also be used for enhancing important details such as image corner angles. In an application of post-processing of images or videos, the digital filter may be used for image zooming, image de-interlacing, post-processing noise reduction enhancement, and the like. In an application of special effect processing of images or videos, the digital filter may also be used for dynamic range compression (Dynamic Range Compression, DRC), image cartoon processing, painting processing, and the like of high dynamic range (High Dynamic Range, HDR) images.
In general, a digital filter used for smoothing or noise reduction may be expressed by a mathematical formula as follows:
      Y    i    =                    ∑                  j          ∈                                          ⁢                      δ            i                          j            ⁢                        ω          ij                ⁢                  I          j                                    ∑                  j          ∈                                          ⁢                      δ            i                          j            ⁢              ω        ij            
where i is a current pixel coordinate, Yi is an output pixel value, Ij is an original image pixel value, δi is a neighborhood of a pixel position i and may be a one-dimensional, two-dimensional, or multi-dimensional space, and ωij is a weight coefficient of the digital filter. A selection rule of the weight coefficient ωij determines the quality of the digital filter. Therefore, calculation about a weight coefficient of a digital filter is a relatively important issue.
In the prior art, a linear filter such as a common low-pass filter, a band-pass filter, or a high-pass filter usually uses space coordinates of pixels to calculate its own weight coefficient, that is, ωij=f(i, j).
In the prior art, the weight coefficient of the linear filter is a function of the space coordinates of the pixels. That is, the weight coefficient of the linear filter only relates to the space coordinates of the pixels, instead of adaptively changing according to image content (such as a strength value of an image). Therefore, when a weight coefficient calculated by using the foregoing method is used for noise reduction of an image or video, blur occurs at an edge of details in the image or video; and when the weight coefficient is used for enhancement of an image or video, an obvious phenomenon of going beyond occurs nearby an edge with a large contrast, that is, a white edge occurs.